import Taro from '@tarojs/taro'

/**
 * 设置标题，兼容H5、小程序
 * @param {String} title
 */
export default function setTitle(title) {
  if (!title) return
  if (process.env.TARO_ENV === 'h5') {
    return (document.title = title)
  }

  Taro.setNavigationBarTitle({
    title
  })
}
